package com.xyzwps.server.paimon.app.dto

import com.xyzwps.server.paimon.ext.validOrThrow
import com.xyzwps.server.paimon.model.entity.Article
import io.konform.validation.Validation
import io.konform.validation.constraints.maxLength
import io.konform.validation.constraints.minLength

data class ArticleUpdateInput(
    val title: String,
    val content: String
) : ValidInput {
    companion object {
        val validator = Validation {
            ArticleUpdateInput::title {
                minLength(Article.TITLE_MIN_LENGTH)
                maxLength(Article.TITLE_MAX_LENGTH)
            }
        }
    }

    override fun validateOrThrow() = validator.validOrThrow(this)
}